﻿miniSched.apiClient = function () {
};

miniSched.apiClient.prototype.urlList = [];
miniSched.apiClient.prototype.jsonApiClient = new miniSched.jsonApiClient();

miniSched.apiClient.prototype.getSettings = function (settings) {
    var self = this;
    return $.extend(true, settings, {
        url: self.urlList[self.urlKey]
    });
};

miniSched.apiClient.prototype.put = function (settings) {
    var self = this;
    return self.jsonApiClient.put(self.getSettings(settings));
}

miniSched.apiClient.prototype.post = function (settings) {
    var self = this;
    return self.jsonApiClient.post(self.getSettings(settings));
};

miniSched.apiClient.prototype.get = function (settings) {
    var self = this;
    return self.jsonApiClient.get(self.getSettings(settings));
};

miniSched.apiClient.prototype.delete = function (settings) {
    var self = this;
    return self.jsonApiClient.delete(self.getSettings(settings));
};

$("a[data-api-url]").each(function () {
    var $this = $(this);
    miniSched.apiClient.prototype.urlList[$this.attr("data-api-url")] = $this.attr("href");
});
